//
//  PKPlayViewController.m
//  PianKe
//
//  Created by lanou on 15/10/6.
//  Copyright (c) 2015年 李伟伟. All rights reserved.
//

#import "PKPlayViewController.h"
#import "PKRequestManager.h"
#import "PKPlayListTableViewController.h"
#import "PKPlayFootViewController.h"
#import "PKPlayMainViewController.h"
#import "PKPlayWebViewController.h"
#import "PKPlayInfoViewController.h"
#import "PKPlayInfoView.h"

@interface PKPlayViewController ()<UIScrollViewDelegate, ttttt>
@property(nonatomic,strong)UIScrollView *mainScrollView;
@property(nonatomic,strong)PKPlayFootViewController *footVC;
@property(nonatomic,strong)PKPlayListTableViewController *listTableViewController;
@property(nonatomic,strong)PKPlayMainViewController *mainVC;
@property(nonatomic,strong)PKPlayWebViewController *webVC;
@property(nonatomic,strong)PKPlayInfoViewController *infoVC;


@end

@implementation PKPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(12, 18, 20, 20);
    backButton.backgroundColor = [UIColor grayColor];
    [backButton setBackgroundImage:[UIImage imageNamed:@"后退"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.topView addSubview:backButton];
    
    _pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(SCREEN_WITDTH * 2/5, SCREEN_HEIGHT-80, SCREEN_WITDTH/5, 10)];
    _pageControl.numberOfPages = 4;
    _pageControl.currentPageIndicatorTintColor = [UIColor greenColor];
    _pageControl.pageIndicatorTintColor = [UIColor grayColor];
    [self.view addSubview:_pageControl];
    
    _footVC = [[PKPlayFootViewController alloc]init];
    _footVC.index = self.index;
    _footVC.dataSourceArray = self.dataSourceArray;
    _footVC.view.frame = CGRectMake(0, SCREEN_HEIGHT-70, SCREEN_WITDTH, 70);
    [self.view addSubview:_footVC.view];
    
    _mainScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 70, SCREEN_WITDTH, SCREEN_HEIGHT-160)];
    _mainScrollView.contentSize = CGSizeMake(SCREEN_WITDTH * 4, SCREEN_HEIGHT-160);
    _mainScrollView.showsHorizontalScrollIndicator = NO;
    _mainScrollView.delegate = self;
    _mainScrollView.pagingEnabled = YES;
    [self.view addSubview:_mainScrollView];
    
    _listTableViewController = [[PKPlayListTableViewController alloc]init];
    _listTableViewController.playVC = self;//把属性赋值
 
    _listTableViewController.index = self.index;
    _listTableViewController.dataSourceArray = self.dataSourceArray;
    _listTableViewController.tableView.frame = CGRectMake(0, 0, SCREEN_WITDTH, SCREEN_HEIGHT-140);
   
   
    
    _mainVC = [[PKPlayMainViewController alloc]init];
    _mainVC.dataSourceArray = self.dataSourceArray;
    _mainVC.index = self.index;
    _mainVC.view.frame = CGRectMake(SCREEN_WITDTH, 0, SCREEN_WITDTH, SCREEN_HEIGHT-140);

    
    _webVC = [[PKPlayWebViewController alloc]init];
    _webVC.dataSourceArray = self.dataSourceArray;
    _webVC.index = self.index;
    _webVC.view.frame = CGRectMake(SCREEN_WITDTH * 2, 0 , SCREEN_WITDTH , SCREEN_HEIGHT - 140);
    
    
    
    _infoVC = [[PKPlayInfoViewController alloc] init] ;
    _infoVC.dataSourceArray = self.dataSourceArray;
    _infoVC.index = self.index;
    _infoVC.view.frame = CGRectMake(SCREEN_WITDTH * 3, 0 , SCREEN_WITDTH , SCREEN_HEIGHT - 140);

    
    [_mainScrollView addSubview:_listTableViewController.tableView];
    [_mainScrollView addSubview:_mainVC.view];
    [_mainScrollView addSubview:_webVC.view];
    [_mainScrollView addSubview:_infoVC.view];
    
    

}

//

- (void)changeOtherVC:(PKRadioDetailModel *)model{
    [_mainVC setConfigureModel:model];
    [_webVC setConfigureModel:model];//    _webVC改变
    [_infoVC setConfigureModel:model];//    _infoVC改变

}

-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    _pageControl.currentPage = scrollView.contentOffset.x/SCREEN_WITDTH;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
